package ui.panels;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Properties;
import main.Main;
import javax.swing.JPanel;

import org.apache.log4j.Logger;

import ui.flowManager.expirimentProperties.ExperimentProperties;
import ui.panels.PanelTypes.PanelType;

public abstract class Panel extends JPanel {

	Logger log = Logger.getLogger(this.getClass());

	public Panel() {
		// this.setPreferredSize(new Dimension(300, 250));
	}

	public static final String PropfileName = System.getProperty(Main.EXPORT_DIR)+"resource\\config.properties";
	//public static final String PropfileName = "config.properties";
	
	/**
	 * @return PanelType - enum
	 */
	public abstract PanelType getPanelType();

	/**
	 *  
	 */
	public abstract void setFromPropertiesConfig(HashMap<String, String> map);

	/**
	 * 
	 */
	public abstract void show(ExperimentProperties props);

	/**
	 * @param key
	 * @return line, a string from configuration file
	 */
	protected String readFromProps(String key) {
		String initProps = key;
		Properties props = new Properties();
		String initString = "";
		// reading value
		try {
			props.load(new FileInputStream(PropfileName));
			initString = props.getProperty(initProps);
		} catch (FileNotFoundException e) {
			log.error("could not find " + PropfileName + " "
					+ e.getStackTrace());
		} catch (IOException e) {
			log.error("error reading from " + PropfileName + " "
					+ e.getStackTrace());
		}
		return initString;
	}
}
